package com.qzdatasoft.mcp.server.demo.resource;

import com.qzdatasoft.mcp.server.common.AbstractResourceProvider;
import com.qzdatasoft.mcp.server.common.ProviderType;
import io.modelcontextprotocol.server.McpSyncServerExchange;
import io.modelcontextprotocol.spec.McpSchema;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.function.BiFunction;

@Service
public class MysqlTable1MetaResourceProvider extends AbstractResourceProvider {

    @Override
    protected McpSchema.Resource getMeta() {
        return new McpSchema.Resource(
                "mysql://table1/meta",
                "table1",
                "meta data",
                "text/plain",
                null
        );
    }

    @Override
    protected BiFunction<McpSyncServerExchange, McpSchema.ReadResourceRequest, McpSchema.ReadResourceResult> handler() {
        return(exchange, request) -> {
            McpSchema.ResourceContents contents = new McpSchema.TextResourceContents(
                    request.uri(), "text/plain", "meta data at here."
            );
            return new McpSchema.ReadResourceResult(List.of(contents));
        };
    }

    @Override
    public ProviderType getType() {
        return ProviderType.RESOURCE;
    }
}
